//
//@File    :	109_usestock2.cpp
//@Time    :	2021/08/27 17:41:09
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	using the Stock class
//

#include <iostream>
#include "10.7_stock20.h"

const int STKS=4;

int main()
{
    Stock stocks[STKS]=
    {
        Stock("NanoSmart",12,20.0),
        Stock("Boffo Objects",200,2.0),
        Stock("Monolithic Obelisks",130,3.25),
        Stock("Fleep Enterprises",60,6.5)
    };
    std::cout<<"Stock holdings:\n";
    int st;
    for(st=0;st<STKS;st++)
    {
        stocks[st].show();
    }
    //set pointer to first element
    const Stock * top=&stocks[0];
    for(st=1;st<STKS;st++)
    {
        top=&top->topval(stocks[st]);
    }
    //now top pointers to the most valueable holding 
    std::cout<<"\nMost valueable holding:\n";
    top->show();
    system("pause");
    return 0;
}